/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.route.system.bean;

import com.route.system.entity.RpsRouteDescription;
import com.route.system.entity.RpsRouteTimeSchedule;
import com.route.system.session.RpsRouteDescriptionFacade;
import com.route.system.session.RpsRouteTimeScheduleFacade;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author neco
 */
@ManagedBean(name="VehicleScheduleBean")
@ViewScoped
public class VehicleScheduleBean implements Serializable{
    private Integer routeDescriptionId;
    @EJB
    private RpsRouteTimeScheduleFacade routeTimeScheduleFacade;
    @EJB
    private RpsRouteDescriptionFacade routeDescriptionFacade;
    
    private RpsRouteDescription routeDescriptionStart = new RpsRouteDescription();
    private RpsRouteDescription routeDescriptionEnd = new RpsRouteDescription();

    public VehicleScheduleBean() {        
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForStart1(Integer RouteDescId,Integer scheduleWeekDay) {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(RouteDescId, scheduleWeekDay);
    }
    public void setRouteDescriptionId(Integer routeDescriptionId) {
        routeDescriptionStart = routeDescriptionFacade.find(routeDescriptionId);
        routeDescriptionEnd = routeDescriptionFacade.findByDescriptionVehicleName(routeDescriptionStart.getDescriptionVehicleName());
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForStart1() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionStart.getDescriptionId(), 1);
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForStart2() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionStart.getDescriptionId(), 2);
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForStart3() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionStart.getDescriptionId(), 3);
    }
   public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForEnd1() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionEnd.getDescriptionId(), 1);
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForEnd2() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionEnd.getDescriptionId(), 2);
    }
    public List<RpsRouteTimeSchedule> findRouteTimeSchedulesForEnd3() {
        return routeTimeScheduleFacade.findByScheduleWeekDayAndScheduleDesc(routeDescriptionEnd.getDescriptionId(), 3);
    }

    public RpsRouteDescription getRouteDescriptionEnd() {
        return routeDescriptionEnd;
    }

    public void setRouteDescriptionEnd(RpsRouteDescription routeDescriptionEnd) {
        this.routeDescriptionEnd = routeDescriptionEnd;
    }

    public RpsRouteDescription getRouteDescriptionStart() {
        return routeDescriptionStart;
    }

    public void setRouteDescriptionStart(RpsRouteDescription routeDescriptionStart) {
        this.routeDescriptionStart = routeDescriptionStart;
    }

    public Integer getRouteDescriptionId() {
        return routeDescriptionId;
    }
    
}
